package com.jikeshijian.concurrent;

/**
 * @Author XuYiHang
 * @Description //TODO
 * @Date 10:49 2019/3/17
 * @Param
 * @retur 解决cpu切换就是需要使用互斥作用
 **/

public class Singleton {
    static Singleton instance;

    static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null)
                    instance = new Singleton();
            }
        }
        return instance;
    }
}
